<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$html_title}</title>
    <link rel="stylesheet" href="/assets/css/backstage/index.css">
    <script src="/assets/libs/jquery/dist/jquery.min.js"></script>
    <script src="/assets/libs/fastadmin-layer/src/layer.js"></script>
</head>

<body>
    <div class="backstage_logo">
        <img class="logo" src="/assets/img/wx_logo.png" alt="logo"></img>
    </div>
    <div class="backstage_put">
        <input type="hidden" name="wx_open_id" id="wx_open_id" value="{$wx_open_id}">
        <input type="hidden" name="type" id="type" value="{$type}">
        <input type="hidden" name="only_no" id="only_no" value="{$only_no}">
        {if $data.code == 200}
        <span>{$data.notice}</span>
        {else/}
        <span style="color: red; font-size: 16px;">{$data.msg}</span>
        {/if}
    </div>
    {if $data.code == 200}
    <div class="backstage_login" id="confirms">确认</div>
    {else/}
    <div class="backstage_login" id="closed">关闭</div>
    {/if}
    <script>
        $(function () {
            var is_true = true;
            $("#confirms").click(function () {
                var wx_open_id = $("#wx_open_id").val();
                var type = $("#type").val();
                var only_no = $("#only_no").val();
                var dats = {
                    wx_open_id: wx_open_id,
                    type: type,
                    only_no: only_no
                }
                if (is_true) {
                    is_true = false
                    $.ajax({
                        url: '{:url("admin/Index/wxLogin")}',
                        type: 'POST',
                        cache: false,
                        data: dats,
                        dataType: 'json',
                        async: false,
                        beforeSend: function () {
                            layer.load();
                        },
                        success: function (data, status) {
                            is_true = true;
                            layer.closeAll('loading');
                            if (data.code === 200) {
                                layer.msg(data.msg, { icon: 1 });
                                setTimeout(function() {
                                    WeixinJSBridge.call('closeWindow')
                                }, 1500)
                            } else {
                                layer.alert(data.msg, {
                                    closeBtn: 0,
                                    anim: 2,
                                    btn: ['关闭'],
                                    icon: 2,
                                    yes: function () {
                                        WeixinJSBridge.call('closeWindow')
                                    }
                                });
                            }
                        }
                    })
                }
            })
            $("#closed").click(function () {
                WeixinJSBridge.call('closeWindow')
            })
        })
    </script>
</body>

</html>